package com.micro.frog.fortune.model.base;

import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author jason.lv
 * @since 2022/1/6 16:38
 */
@ApiModel(value = "默认响应")
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Resp {

  @ApiModelProperty(value = "返回码", example = "0")
  @JsonProperty("code")
  private Integer code = 0;

  @ApiModelProperty(value = "错误信息", example = "SUCCESS")
  @JsonProperty("msg")
  private String msg = "成功";

  public boolean isSuccess(){
    return Integer.valueOf(0).equals(code);
  }

  public static Resp generate(Integer code, String msg) {
    Resp response = new Resp();
    response.setCode(code);
    response.setMsg(msg);
    return response;
  }

  public static Resp generate() {
    return new Resp();
  }
}


